package algorithms.que14;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

/**
 * @功能
 * @创建时间 2020/9/20
 */
public class E1d4d44 {
    public static void main(String[] args)
    {
        for (int i=2;i<=10000000;i=i+i)
        {
            int[] data=new int[i];
            int count=0;
            boolean notRepeart=true;
            while (notRepeart)
            {
                int r= StdRandom.uniform(i);
                if(data[r]==0)
                {
                    count++;
                    data[r]=1;
                }
                else
                {
                    notRepeart=false;
                }
            }//end while
            StdOut.printf("N=%9d count=%7d sqrt(pi*N/2)=%6.1f\n",i,count,Math.sqrt(Math.PI*i/2));
        }//end for
    }//end main
}
